#include<iostream>
#include<list>
using namespace std;
//decltype的应用多用在泛性编程中，在一个类模板中添加遍历容器的函数
template<class T>
class Container
{
public:
    void func(T& c)
    {
        for (m_it = c.begin(); m_it != c.end();++m_it)
        {
            cout << *m_it << " ";
        }
        cout << endl;
    }
private:
        //T::iterator m_it;错误 无法识别迭代器类型
    
    decltype(T().begin()) m_it;
};
int main()
{
    list<int> ls{1,2,3,4,5,6,7,8,9};
    const list<int> ls1{1, 2, 3, 4, 5, 6, 7, 8, 9};
    Container<list<int>> c;
    Container<const list<int>> c1;
    c.func(ls);
    c1.func(ls1);
    return 0;
}